import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;


public class Faculty implements Serializable, Iterator<Person>
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6797178694652970963L;
	private String name; 
	private ArrayList<Person> staff = new ArrayList<Person>();
	private String address;
	private String type;
	private int totalFacultyPapers;
	private int totalFacultyCitations;
	int index = 0;
	
	public Faculty()
	{
	}
	
	public void addStaffMember(Person p)
	{
		this.staff.add(p);
	}
	
	public int getTotalStaffMembers()
	{
		return staff.size();
	}
	
	public void printAll()
	{
		Iterator<Person> it = staff.iterator();
		while(it.hasNext()) 
		{
			Person p = (Person)it.next();
			System.out.println(p.formatName());
		}
	}

	@Override
	public boolean equals(Object obj) 
	{
		Faculty temp = (Faculty) obj;
		if(this.name == temp.name && this.address == temp.address && this.type == temp.type
				&& this.totalFacultyCitations == temp.totalFacultyCitations && this.totalFacultyPapers == temp.totalFacultyPapers)
			return true;
		else
			return false;
	}
	
	
	public StringBuffer returnNames()
	{
		StringBuffer buff = new StringBuffer("");
		Iterator<Person> it = staff.iterator();
		while(it.hasNext()) 
		{
			Person p = (Person)it.next();
			buff.append(p.getName() + " ");
		}
		return buff;
	}
	
	
	/* 
	 * GETTERS & SETTERS
	 */
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public ArrayList<Person> getStaff() {
		return staff;
	}
	public void setStaff(ArrayList<Person> staff) {
		this.staff = staff;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public void setTotalFacultyCitations(int totalFacultyCitations) {
		this.totalFacultyCitations = totalFacultyCitations;
	}
	public int getTotalFacultyCitations() {
		return totalFacultyCitations;
	}
	public void setTotalFacultyPapers(int totalFacultyPapers) {
		this.totalFacultyPapers = totalFacultyPapers;
	}
	public int getTotalFacultyPapers() {
		return totalFacultyPapers;
	}

	@Override
	public boolean hasNext() 
	{
		if(index < staff.size())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	@Override
	public Person next() 
	{		
		Person p = staff.get(index);
		index++;
		return p;
	}

	@Override
	public void remove() 
	{	
		staff.trimToSize();
		staff.remove(staff.size()-1);
	}

	/**
	 * @return
	 */
}
